/*sj6o7+EFvqrNBEa2h23fFyapbCu6jppqgO7Pg5Ykwls0iqh9eV3nVxPjFAbfMGN5*/
/*
 * @Descripttion: 组织
 * @version:
 * @Author: Chendch
 * @Date: 2020-10-14 15:49:38
 * @LastEditors: Chendch
 * @LastEditTime: 2020-10-14 16:14:36
 */
import { ajax, toast } from 'nc-lightapp-front';
import {Urls} from "../CONSTANCE";
function  queryorg(phone) {
    return new Promise( (resolve, reject) => {
        ajax({
            url:Urls.queryorgUrl,
            data:{
              phone:phone,
              type:1
            },
            async: false,
            success : (res) => {
                const {success, data} = res;
                if(!success) {
                    resolve({})
                }
                resolve(data);
            },
            error: (msg) => {
                toast({content:msg.message,color:'danger'});
                reject("error");
            }
        })
    })
}

 /**
   * 刷新组织权限
   */
function  updateOrgsgrid (phone) {
    return new Promise( (resolve, reject) => {
        ajax({
            url: Urls.orgsgridUrl,
            data: {
                phone: phone,
                type: 1
            },
            async: false,
            success: (res) => {
                const {success, data} = res;
                if(!success) {
                    resolve({})
                }
                resolve(data);
            },
            error: (msg) => {
                toast({ content: msg.message, color: 'danger' });
                reject("error");
            }
        });
    })

}
  /**
   * 删除移动用户的组织权限
   */
function delOrg (vo = {}) {
    return new Promise( (resolve, reject) => {
        ajax({
            url: Urls.orgdeleteUrl,
            data: vo,
            async: false,
            success: (res) => {
                const {success, data} = res;
                if(!success) {
                    resolve({})
                }
                toast({content:'删除成功！',color:'success'});
                resolve(data);
            },
            error: (msg) => {
                toast({ content: msg.message, color: 'danger' });
                reject("error");
            }
        });
    })

}



export {
    queryorg,
    updateOrgsgrid,
    delOrg
}
/*sj6o7+EFvqrNBEa2h23fFyapbCu6jppqgO7Pg5Ykwls0iqh9eV3nVxPjFAbfMGN5*/
